<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------
namespace Home\Service;

class TagService
{
	
    /**
     * 保存图片信息
     * @return unknown
     */
    public function save($tag, $creator){
        //step-1: 查询是否存在
        $Model = D('Tag');
        
        $tagExist = $Model->where(array("name"=>$tag['name']))->find();
        if(!empty($tagExist)) {
            return $tagExist['id'];
        }
        //step-2: 设置创建人
        $tag['creator'] = $creator;
        
        //step-3: 保存
        return $Model->add($tag);
       
        
	}
	
	
}